﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Drawing;

namespace Coot
{
    /// <summary>
    /// Interaction logic for PhotoControl.xaml
    /// </summary>
    public partial class PhotoControl : UserControl
    {
        [System.Runtime.InteropServices.DllImport("gdi32")]
        static extern int DeleteObject(IntPtr o);
        readonly double screenWidth = SystemParameters.VirtualScreenWidth;
        readonly double screenHeight = SystemParameters.VirtualScreenHeight;

        public PhotoControl()
        {
            InitializeComponent();
        }

        public PhotoControl(BitmapImage photo, int width, int height, string cap)
        {
            InitializeComponent();
            System.Net.ServicePointManager.Expect100Continue = false;
            
            this.Width = width + 50;
            this.Height = height + 85;

            Random random = new Random();

            double left = random.Next((int)(screenWidth - this.Width));
            double top = random.Next((int)(screenHeight - this.Height));
            this.Margin = new Thickness(left, top, 0, 0);

            RotateTransform rotation = new RotateTransform((random.NextDouble() - 0.5) * 16, this.Width / 2, this.Height / 2);
            this.RenderTransform = rotation;

            image.Source = photo;
    
            caption.Text = cap;
        }
    }
}
